<?php

namespace App\Console\Commands;

use App\Models\Product;
use App\Services\ConfigService;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Cache;
use Rizhou\PageCache\PageCache;

class RandProduct extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'rand:product';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {

        $count = app(\App\Services\Compose::class)->start();
        $this->info('成功：'.$count);
        /*$products = Product::get();
        foreach ($products as $product){
            $sort = rand(0,10000);
            $product->sort = $sort;
            $product->save();
            usleep(200000);
        }

        foreach(config('global.cache')  as $key){
            Cache::forget($key);
        }
        ConfigService::cache();

        app(PageCache::class)->clear();*/

    }
}
